package com.gxa.test.stafftest;

import com.alibaba.fastjson.JSON;
import com.gxa.dao.staffdao.StaffMapper;
import com.gxa.pojo.staff.UserStaff;
import com.gxa.service.staffservice.StaffService;
import com.gxa.service.staffservice.impl.StaffServiceImpl;
import com.gxa.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

import java.util.Date;
import java.util.List;

public class Demo {
    private StaffService staffService = new StaffServiceImpl();
    @Test
    public void findAll(){
        List<UserStaff> all = staffService.findAll();
        System.out.println(all);
    }

    @Test
    public void cha(){
        SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        StaffMapper mapper = sqlSession.getMapper(StaffMapper.class);
        UserStaff userStaff = new UserStaff();
        userStaff.setStaff_id(2);
        userStaff.setName("朱元璋");
        userStaff.setRfid("qwertasdfgzx");
        userStaff.setIdcard("511322199802168974");
        userStaff.setPhonenumber("14789467485");
        userStaff.setEntrytime(new Date());
        userStaff.setPwd("12347892");
        userStaff.setBorntime(new Date());
        userStaff.setWork_status(1);
        userStaff.setSex("男");
        userStaff.setLevel(1);
        userStaff.setPhoto("iuhibu");
        mapper.addStaff(userStaff);
    }

    @Test
    public void findId() {
        StaffService staffService = new StaffServiceImpl();
        UserStaff byId = staffService.findById(1);
        System.out.println(byId);
    }

    @Test
    public void up(){
        StaffService staffService = new StaffServiceImpl();
        UserStaff userStaff =new UserStaff();
        userStaff.setStaff_id(3);
        userStaff.setName("张飞");
        staffService.update(userStaff);
    }
    @Test
    public void cl(){
        StaffService staffService = new StaffServiceImpl();
        staffService.cancleclock(3);
    }
}
